﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

namespace Xiaov.SmartWeb.Application
{
  public partial class WebForm1 : System.Web.UI.Page
  {
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
      StringBuilder xml = new StringBuilder();
      xml.Append(@"<?xml version=""1.0""?>
<?mso-application progid=""Excel.Sheet""?>
<Workbook xmlns=""urn:schemas-microsoft-com:office:spreadsheet""
 xmlns:o=""urn:schemas-microsoft-com:office:office""
 xmlns:x=""urn:schemas-microsoft-com:office:excel""
 xmlns:ss=""urn:schemas-microsoft-com:office:spreadsheet""
 xmlns:html=""http://www.w3.org/TR/REC-html40"">
 <DocumentProperties xmlns=""urn:schemas-microsoft-com:office:office"">
  <Created>1996-12-17T01:32:42Z</Created>
  <LastSaved>2013-12-23T08:51:20Z</LastSaved>
  <Version>11.9999</Version>
 </DocumentProperties>
 <OfficeDocumentSettings xmlns=""urn:schemas-microsoft-com:office:office"">
  <RemovePersonalInformation/>
 </OfficeDocumentSettings>
 <ExcelWorkbook xmlns=""urn:schemas-microsoft-com:office:excel"">
  <WindowHeight>4530</WindowHeight>
  <WindowWidth>8505</WindowWidth>
  <WindowTopX>480</WindowTopX>
  <WindowTopY>120</WindowTopY>
  <AcceptLabelsInFormulas/>
  <ProtectStructure>False</ProtectStructure>
  <ProtectWindows>False</ProtectWindows>
 </ExcelWorkbook>
 <Styles>
  <Style ss:ID=""Default"" ss:Name=""Normal"">
   <Alignment ss:Vertical=""Bottom""/>
   <Borders/>
   <Font ss:FontName=""宋体"" x:CharSet=""134"" ss:Size=""12""/>
   <Interior/>
   <NumberFormat/>
   <Protection/>
  </Style>
  <Style ss:ID=""s18"" ss:Name=""货币[0]"">
   <NumberFormat ss:Format=""_ &quot;￥&quot;* #,##0_ ;_ &quot;￥&quot;* \-#,##0_ ;_ &quot;￥&quot;* &quot;-&quot;_ ;_ @_ ""/>
  </Style>
  <Style ss:ID=""s23"">
   <Alignment ss:Horizontal=""Center"" ss:Vertical=""Bottom""/>
  </Style>
 </Styles>
 <Worksheet ss:Name=""Sheet1"">
  <Table ss:ExpandedColumnCount=""4"" ss:ExpandedRowCount=""3"" x:FullColumns=""1""
   x:FullRows=""1"" ss:DefaultColumnWidth=""54"" ss:DefaultRowHeight=""14.25"">
   <Row>
    <Cell ss:StyleID=""s18""/>
    <Cell ss:StyleID=""s18""/>
    <Cell ss:StyleID=""s18""/>
    <Cell ss:StyleID=""s18""/>
   </Row>
   <Row>
    <Cell ss:MergeAcross=""1"" ss:MergeDown=""1"" ss:StyleID=""s23""/>
   </Row>
  </Table>
  <WorksheetOptions xmlns=""urn:schemas-microsoft-com:office:excel"">
   <Selected/>
   <Panes>
    <Pane>
     <Number>3</Number>
     <ActiveRow>8</ActiveRow>
     <ActiveCol>3</ActiveCol>
    </Pane>
   </Panes>
   <ProtectObjects>False</ProtectObjects>
   <ProtectScenarios>False</ProtectScenarios>
  </WorksheetOptions>
 </Worksheet>
 <Worksheet ss:Name=""Sheet2"">
  <Table ss:ExpandedColumnCount=""0"" ss:ExpandedRowCount=""0"" x:FullColumns=""1""
   x:FullRows=""1"" ss:DefaultColumnWidth=""54"" ss:DefaultRowHeight=""14.25""/>
  <WorksheetOptions xmlns=""urn:schemas-microsoft-com:office:excel"">
   <ProtectObjects>False</ProtectObjects>
   <ProtectScenarios>False</ProtectScenarios>
  </WorksheetOptions>
 </Worksheet>
 <Worksheet ss:Name=""Sheet3"">
  <Table ss:ExpandedColumnCount=""0"" ss:ExpandedRowCount=""0"" x:FullColumns=""1""
   x:FullRows=""1"" ss:DefaultColumnWidth=""54"" ss:DefaultRowHeight=""14.25""/>
  <WorksheetOptions xmlns=""urn:schemas-microsoft-com:office:excel"">
   <ProtectObjects>False</ProtectObjects>
   <ProtectScenarios>False</ProtectScenarios>
  </WorksheetOptions>
 </Worksheet>
</Workbook>");
      xml.Clear();
      System.Web.HttpContext.Current.Response.Clear();
      System.Web.HttpContext.Current.Response.Buffer = true;
      System.Web.HttpContext.Current.Response.ContentEncoding = Encoding.GetEncoding("utf-8");
      System.Web.HttpContext.Current.Response.Charset = "";
      System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + "a.xls");
      System.Web.HttpContext.Current.Response.ContentType = "text/xml";
      Excel.ExportExcel excel = new Excel.ExportExcel();
      xml.Append(excel.GetXML("HG02", "CL0002", "2014", "2"));
      System.Web.HttpContext.Current.Response.Write(xml.ToString());
      System.Web.HttpContext.Current.Response.End();
    }
  }
}